Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/next/pages/share/projects/[project_id].tsx
Views: 687
/*1* This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45/*6Page for a given project.7Show all the public paths in a given project, and maybe other information about the project?8*/910import { join } from "path";11import basePath from "lib/base-path";12import { isUUID } from "lib/share/util";13import withCustomize from "lib/with-customize";14import getProject from "lib/share/get-project";15import getProjectInfo from "lib/project/info";16import getProjectOwner from "lib/project/get-owner";17import getOwnerName from "lib/owner/get-name";18import Project from "components/project/project";1920export default Project;2122export async function getServerSideProps(context) {23const { project_id } = context.params;24if (!isUUID(project_id)) {25return { notFound: true };26}27let props;28try {29const project = await getProject(project_id, [30"name",31"title",32"description",33"avatar_image_full",34]);35if (project.name) {36// This project probably has a nice vanity name. Possibly redirect to that instead.37const owner_id = await getProjectOwner(project_id);38const owner = await getOwnerName(owner_id);39if (owner) {40return { props: { redirect: join(basePath, owner, project.name) } };41}42}43props = {44project_id,45...(await getProjectInfo(project_id, context.req)),46...project,47};48} catch (_err) {49// console.warn(_err)50return { notFound: true };51}5253return await withCustomize({ context, props });54}555657